$(function() {
    $.ajax({
        url: "../data/index.json",
        type: "get",
        // 请求回来的数据是json
        dataType: "json",
        success: function(data) {
            var strDom = ''
                // ele是对应下标的数组
            var list = data["goodslist"];
            $.each(list, function(i) {
                var goods = `
            <div>
            <a href="./singlegoods.html?data-id=${list[i].id}">
                <img src="${list[i].imgurl}" alt="">
                <p>${list[i].title}</p>
                <p>￥<span>${list[i].price}</span></p>
            </a>
        </div>
                `
                strDom += goods
            })
            $('.banner').html(strDom);
        }
    })

})